import {
  IsNotEmpty,
  IsString,
  MinLength,
  MaxLength,
  IsOptional,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class LoginDto {
  @ApiProperty({ description: '用户名/邮箱/手机号', example: 'testuser' })
  @IsNotEmpty({ message: '用户名不能为空' })
  @IsString({ message: '用户名必须是字符串' })
  @MaxLength(50, { message: '用户名最多50个字符' })
  username: string;

  @ApiProperty({ description: '密码', example: 'password123' })
  @IsNotEmpty({ message: '密码不能为空' })
  @IsString({ message: '密码必须是字符串' })
  @MinLength(6, { message: '密码至少6个字符' })
  password: string;

  @ApiProperty({ description: '验证码', example: '123456', required: false })
  @IsOptional()
  @IsString({ message: '验证码必须是字符串' })
  @MaxLength(6, { message: '验证码最多6个字符' })
  captcha?: string;

  @ApiProperty({
    description: '验证码UUID',
    example: 'uuid-string',
    required: false,
  })
  @IsOptional()
  @IsString({ message: '验证码UUID必须是字符串' })
  captchaUuid?: string;
}

export class RefreshTokenDto {
  @ApiProperty({ description: '刷新令牌', example: 'refresh-token-string' })
  @IsNotEmpty({ message: '刷新令牌不能为空' })
  @IsString({ message: '刷新令牌必须是字符串' })
  refreshToken: string;
}
